
import {combineReducers} from 'redux'
import defaultState from '../state'
import {SET_PAGE_TITLE,SET_INFO_LIST,DEL,INCRE,SET} from '../actions'
 
 
//一个reducer 就是一个函数
function pageTitle ( state = defaultState.pageTitle, action){
    // 不同的action 有不同的处理逻辑
    switch (action.type) {
        case SET_PAGE_TITLE:
            return action.data
        default:
            return state
    }
}
 
function infoList (state = defaultState.infoList, action){
    switch (action.type) {
        case SET_INFO_LIST:
            return action.data
        default:
            return state
    }
}

function count(state=defaultState.count,action){
    switch(action.type){
        case DEL:
            return state-1
        case INCRE:
            return state+1
        default:
            return state
    }
}

function userInfo(state=defaultState.userInfo,action){
    switch(action.type){
        case SET:
            return action.data
        default:
            return state
    }
}
 
export default combineReducers({
    pageTitle,
    infoList,
    count,
    userInfo
})